import React, { useEffect } from 'react'
import { Button, Mask, Space, Modal, Toast, Divider } from 'antd-mobile'
import { useNavigate, useSearchParams } from 'react-router-dom'
import axios from 'axios'
axios.defaults.baseURL = 'http://127.0.0.1:3000'
export default function Cancel() {
    const navigate = useNavigate()
    const [params] = useSearchParams()
    const id = params.get('id')
    const actions = [
        {
            key: 'online',
            text: '取消订单',
            primary: true,
            onclick: () => {
                console.log('a');
            }
        },
        {
            key: 'download',
            text: '点错了',
            onclick: () => {
                console.log('v');

            }
        },
    ]
    useEffect(() => {
        Modal.show({
            content: '人在天边月上明，风初紧，吹入画帘旌',
            closeOnAction: true,
            actions: actions,
            onAction: (aa) => {
                if (aa.text === '点错了') {
                    navigate(-1)
                } else {
                    axios.get(`/OrderRouter/OrderDel?id=${id}`).then(res => {
                        navigate('/order')
                    })
                }

            }
        })
    }, [])
    return (
        <div>
            <Mask visible={true} >
                <div style={{ margin: '42rem 19rem' }}></div>
            </Mask>
        </div>
    )
}
